/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sync.model;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;


/**
 *
 * @author yarden
 */
public class Assignment {
      
    public enum Status {
        InProgress("InProgress"), 
        OnHold("OnHold"), 
        Done("Done");
        
        private final String text;
        
        Status(String text) {
            this.text = text;
        }
        
        @Override
        public String toString() {
            return text;
        }
        
        public static Status getStatus(String status) {
            if (InProgress.text.equals(status)) return InProgress;
            if (OnHold.text.equals(status)) return OnHold;
            if (Done.text.equals(status)) return Done;
            return InProgress;
        }
    };
    
    private String id;
    private String name = "";
    private String user="";

    
    private String assigned = "";
    private String modified = "";
    private String completed = "";
    private String due = "";
    private String schema = "";
    private String schemaId = "";

    private String  comments = "";
    
    private List<AssignmentItem> items = new ArrayList<AssignmentItem>();
    
    
    public Assignment(String id) {
        this.id = id;    
    }
    
    
    public String getId() {
        return id;
    }
    
    public String getName() {
        return name;
    }
    
    public void setName(String name) {
        this.name = name;
        
    }
    
    public String getUser() {
        return user;
    }
    
    public void setUser(String user) {
        this.user = user;
    }
    public String getAssigned() {
        return assigned;
    }
    
    public void setAssigned(String assigned) {
        this.assigned = assigned;
    }
    
    public String getModified() {
        return modified;
    }
    
    public void setModified(String date) {
        modified = date;
    }
    
    public String getCompleted() {
        return completed;
    }
    
    public void setCompleted(String completed) {
        this.completed = completed;
    }
    
    public String getDue() {
        return due;
    }
    
    public void setDue(String due) {
        this.due = due;
    }
   
    public String getSchema() {
        return schema;
    }
    
    public void setSchema(String schema) {
        this.schema = schema;
    }
    
    public String getSchemaId() {
        return schemaId;
    }
    
    public void setSchemaId(String id) {
        schemaId = id;
    }
    public String getComments() {
        return comments;
    }
    
    public void setComments(String comments) {
        this.comments = comments;
    }
    
    public void addItem(AssignmentItem item) {
        items.add(item);
        item.setAssignment(this);
    }
    
    public void setItems(List<AssignmentItem> items) {
        this.items = items;
        Iterator<AssignmentItem> i=items.iterator(); 
        while (i.hasNext())
            i.next().setAssignment(this);
    }
    
    public List<AssignmentItem> getItems() {
        return items;
    }
}
